package com.tuozixuan;

import java.util.HashMap;
import java.util.Map;

import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;

public class AviatorCompileDemo {

	public static void main(String[] args) {
		String expression = "a-(b-c)>100";
        Expression compiledExp = AviatorEvaluator.compile(expression);
        
        Map<String, Object> env = new HashMap<>();
        env.put("a", 100.3);
        env.put("b", 45);
        env.put("c", -199.100);
        Boolean result = (Boolean) compiledExp.execute(env);
        System.out.println(result);
        
        Map<String, Object> env1 = new HashMap<>();
        env1.put("a", 350.3);
        env1.put("b", 45);
        env1.put("c", -149.100);
        Boolean result1 = (Boolean) compiledExp.execute(env1);
        System.out.println(result1);
	}

}
